package com.Lgwd.controller.dropgoodsController;


import com.Lgwd.dao.DropDao;
import com.Lgwd.dao.ItemDao;
import com.Lgwd.entity.DropGoodsEntity;
import com.Lgwd.service.backService.DropGoodsService;
import com.Lgwd.utils.ResponseData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@Service
@CrossOrigin
public class DropGoodsController {


    @Autowired
    DropGoodsService dropGoodsService;

    /**
     * 物品掉落接口  怪物死亡后自动调用
     * 根据传入账号来添加所掉落装备
     * 所有装备均可掉落
     *
     * @param dropDao
     * @return
     */
    @RequestMapping("/returnGoods")
    public ResponseData returnGoods(@RequestBody DropDao dropDao) {
        ItemDao dropGoodsEntity = dropGoodsService.returnGoods(dropDao);
        if(dropGoodsEntity==null){
            return ResponseData.defaultFail("未掉落物品");
        }else {
            log.info("用户【"+dropDao.getUser_account()+"】掉落了【"+dropGoodsEntity.getItem_name()+"】");
            return ResponseData.defaultSuccess(dropGoodsEntity);
        }

    }
}
